<template>
  <el-container class="is-vertical" style="height: 100%">
    <headers/>
    <el-container>
      <asides/>
      <el-container class=" is-vertical loadingtext">
        <el-main class="main-moudle " id="app-main">

            <router-view ></router-view>


        </el-main>
      </el-container>
    </el-container>
  </el-container>



</template>
<script>
import headers from '@/components/header';
import asides from '@/components/aside';
import footers from '@/components/footer';
// import { changeCounts, insert } from '@/api/dice';
import { getToken, removeToken } from '@/store/getters';
export default {
  data () {
    return {
      timeOut: '',
      second: 30 * 60
    };
  },
  methods: {
    //页面15分钟无操作时返回首页
    startTimer () {
      let that = this;
      var t = setInterval(function () {
        that.second = parseInt(that.second) - 1;
        if (that.second == 0) {
          clearInterval(t);
        }
      }, 1000);
    },
    isTimeOut () {
      let that = this;
      if (that.$route.path != '/') {
        that.startTimer();
      }
      document.body.onmouseup = that.resertSecond;
      document.body.onmousemove = that.resertSecond;
      document.body.onkeyup = that.resertSecond;
      document.body.onclick = that.resertSecond;
      document.body.ontouchend = that.resertSecond;
    },
    resertSecond () {
      this.second = 30 * 60;
    }
  },
  watch: {
    second (v) {
      if (v == 0) {
        removeToken();
        this.$router.push({
          path: '/'
        });
      }
    }
  },
  created () {
    this.isTimeOut();
    if (!getToken()) {
      this.$router.push({
        path: '/'
      });
    }
  },
  components: {
    headers,
    asides,
    footers
  }
};
</script>
